import argparse
import importlib
import sys
import os
sys.path.append(os.path.abspath('.'))

from context import update_context
from utils import LOG

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='A entry script to execute the fake data generator.')
    parser.add_argument('--name', '-n', type=str, required=True, help='the name of generated file, format is "{package_name}.{module_name}".')
    parser.add_argument('--zip_filename', '-sn', type=str, help='the name of zip file.')
    parser.add_argument('--row_number', '-rn', type=int, help='the number of generated rows.')
    args = parser.parse_args()

    update_context({
        'zip_filename': args.zip_filename
    })

    module_name = args.name
    module = importlib.import_module(module_name)
    LOG.info(f"Generating {args.row_number} records...")
    row_number = args.row_number if args.row_number else 10
    module.generate_fake_data_file(row_number)
